<template>
  <div>
    <div id="tree" style="width: 230px; height: 300px"></div>
  </div>
</template>

<script setup>
import { ref, toRefs, reactive, onMounted } from "vue";
import { bing } from "@/http/chart.js";
import * as echarts from "echarts";
const state = reactive({
  list: [],
});
const listgett = async () => {
  const res = await bing();
  state.list = res.data;
  console.log(state.list,"3333");
  chartOpt();
};
const chartOpt = () => {
  const chartDom = document.getElementById("tree");
  const myChart = echarts.init(chartDom);

  let option = {
    title: {
      text: "大区营销图示",
      top: "12%",
      left: "-2%",
    },
    tooltip: {
      trigger: "item",
    },
    series: [
      {
        type: "pie",
        radius: ["40%", "70%"],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: "#fff",
          borderWidth: 2,
        },
        label: {
          show: false,
          position: "center",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: "30",
            fontWeight: "bold",
          },
        },
        labelLine: {
          show: false,
        },
        data: [...state.list],
      },
    ],
  };

  option && myChart.setOption(option);
};
onMounted(() => {
  listgett();
  setTimeout(() => {
    chartOpt();
  }, 1000);
});
</script>

<style lang="scss" scoped>
</style>